<template>
  <div>
    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="用户名">
        <el-input v-model="formInline.user" placeholder="用户名"></el-input>
      </el-form-item>
      <el-form-item label="id">
        <el-input
          v-model="formInline.id"
          placeholder="id"
          ref="sousuoid"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableData" style="width: 100%" height="400">
      <el-table-column fixed prop="logId" label="id" width="100">
      </el-table-column>
      <el-table-column prop="logUsername" label="用户名" width="150">
      </el-table-column>
      <el-table-column prop="logName" label="真实姓名" width="200">
      </el-table-column>
      <el-table-column prop="logDesc" label="动态" width="450">
      </el-table-column>
      <el-table-column prop="logCreatetime" label="创建时间" width="200">
      </el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="1"
        :page-sizes="[10, 20, 30, 40]"
        :page-size="limit"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { yhrz } from "@/apis/lihan/Index.js";
export default {
  data() {
    return {
      formInline: {
        user: "",
        id: "",
      },
      tableData: [],
      page: 1,
      limit: 5,
      total: 1,
    };
  },
  mounted() {
    this.link();
  },
  methods: {
    link() {
      yhrz(this.page, this.limit).then((ok) => {
        console.log(ok, 77777);
        this.tableData = ok.data.data.records;
        this.page = ok.data.data.pages;
        this.limit = ok.data.data.size;
        this.total = ok.data.data.total;
      });
    },
    handleSizeChange(val) {
      (this.limit = val), this.link();
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      (this.page = val), this.link();
      console.log(`当前页: ${val}`);
    },
  },
};
</script>

<style scoped>
</style>